package com.fiximusic.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class BasePathInterceptor extends HandlerInterceptorAdapter{

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		StringBuffer basePath = new StringBuffer( 512);
		basePath.append( request.getScheme()).append( "://").append( request.getServerName());
		basePath.append( ":").append( request.getServerPort()).append( request.getContextPath()).append("/");
        request.setAttribute("basePath", basePath.toString());
        System.out.println( basePath.toString());
        return true;
    }

	
}
